package ma.co.ba.BusinessApplications.business.tickets.impl;

import java.util.List;

import ma.co.ba.BusinessApplications.business.tickets.TicketBusiness;
import ma.co.ba.BusinessApplications.dao.commons.DAOServices;
import ma.co.ba.BusinessApplications.model.Criticite;
import ma.co.ba.BusinessApplications.model.DAT;
import ma.co.ba.BusinessApplications.model.Etat;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("ticketBusiness")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class TicketBusinessImpl implements TicketBusiness {

	@Autowired
	DAOServices daoServices;

	public DAT getDATById(int id) {
		return (DAT) daoServices.getEntityById2(DAT.class, id);
	}

	public List<DAT> getAllDats() {
		return daoServices.getEntities(DAT.class);
	}

	public Criticite getCriticiteById(int id) {
		return (Criticite) daoServices.getEntityById2(Criticite.class, id);
	}

	public List<Criticite> getAllCriticites() {
		return daoServices.getEntities(Criticite.class);
	}

	public Etat getEtatById(int id) {
		return (Etat) daoServices.getEntityById2(Etat.class, id);
	}

	public List<Etat> getAllEtats() {
		return daoServices.getEntities(Etat.class);
	}

	
	public Etat getEtatByValue(String value) {
		return (Etat) daoServices.getUniqueEntitiyByProperty(Etat.class,
				"libelleEtat", value);

	}
}
